package com.bafa.gadgets.events;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.bafa.debug.Debug;
import com.bafa.front.presentationbeans.LeagueBean;
import com.bafa.front.utils.FrontUtils;
import com.bafa.objects.PageBean;
import com.bafa.objects.season.Division;
import com.bafa.services.RetrieveServices;

public class LeagueEvent extends Event {

	@Override
	public void doEvent(HttpServletRequest request,
			HttpServletResponse response, PageBean page) {
		
		Division division = new Division();
		
		
		String seasonId = new Integer(FrontUtils.getThisSeason(request).getId()).toString();
		Debug.debug(this.getClass(),"doEvent","SEASON ID IS "+seasonId);
		division = RetrieveServices.getDivision(seasonId,request.getParameter("Division"));
		Debug.debug(this.getClass(),"doEvent","DIVISION IS "+division);
		LeagueBean leagueBean = new LeagueBean(division.teamIdArray(),new Integer(seasonId),division.getDivision(),division.isCompleted());
		Debug.debug(this.getClass(),"doEvent","LEAGUE BEAN IS "+leagueBean);
		request.setAttribute("DIVISION",leagueBean);
	}

}
